home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d20
/
doorskl3.arc
/
XBBSMSG.ARC
/
IDXMSG.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-15
|
1KB
|
51 lines
#include <stdlib.h>
#include <string.h>
#include "xmsg.h"
#define STARTPTRS 512
#define INCPTRS 128
#define IDX_ERRNOERR 0
#define IDX_ERRNOMEM 1
#define IDX_ERRNOTEXT 2
#ifdef __TURBOC__
#define _fastcall pascal
#endif
int _fastcall index_msg (IMSG *m,int width) { \* index the lines of a msg body */
char *t = m->text,*p,*r,line[133];
word pt = 0,nh = 0;
if(!t || !*t) {
return IDX_ERRNOTEXT;
}
p = malloc(STARTPTRS * sizeof(char *));
if(!p) return IDX_ERRNOMEM;
nh = STARTPTRS;
while(*t) {
p[pt] = write_line(line,&t,width,(int)m->ctla);
if(pt + 1 >= nh && *t) {
r = realloc(p,(nh + INCPTRS) * sizeof(char *));
if(!r) {
break;
}
p = r;
nh += INCPTRS;
continue;
}
if(*t) pt++;
}
m->numptrs = pt;
r = realloc(p,pt + 1);
if(r) p = r;
m->ptrs = p;
return IDX_ERRNOERR;
}